package week3;
import java.util.*;
//import java.lang.Math;
abstract class Shape{
	 final double PI = 3.14;
	 public abstract double getArea();
	 public abstract double getPerimeter();
	 
	 public double sumAllArea(int a1,int a2,Rectangle[] p1,Circle[] p2){
		 double sum1=0;
		 for(int i=0;i<a1;i++){
			 sum1=sum1+p1[i].getArea(); 
		 }
		 for(int i=0;i<a2;i++){
			 sum1=sum1+p2[i].getArea(); 
		 }
		 return sum1;
	 }
	 
	 public double  sumAllPerimeter(int a1,int a2,Rectangle[] p1,Circle[] p2){
		 double sum2=0;
		 for(int i=0;i<a1;i++){
			 sum2=sum2+p1[i].getPerimeter(); 
		 }
		 for(int i=0;i<a2;i++){
			 sum2=sum2+p2[i].getPerimeter(); 
		 }
		 return sum2;
	 }
	 
}


class Rectangle extends Shape {
	private int width;
	private int length;
	
	
	public Rectangle(int width,int length){
		this.width=width;
		this.length=length;
	
	}
	
	
	public  double getPerimeter(){
		this.width=width;
		this.length=length;
	
		double c1=(width+length)*2;
		return c1;
	}
	
	public  double getArea(){
		this.width=width;
		this.length=length;
		double s1=width*length;
		return s1;
	}


	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
	
	
}


class Circle  extends Shape{
	private int radius;
	
	public Circle(int radius){
		this.radius=radius;
	}
	
	
	public double getPerimeter(){
		this.radius=radius;
		double c2=(double)(2*super.PI*radius);
		return c2;
	}
	
	public double getArea(){
		this.radius=radius;
		double s2=(double)(super.PI*radius*radius);
		return s2;
	}


	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}


	


	
	
	
}


public class pta04 {
	public static void main(String[] args) {
		//int r=new Math();
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		int a1=0,a2=0;
		ArrayList b1=new ArrayList();
		ArrayList b2=new ArrayList();
		for(int i=0;i<n;i++){
			String ss=sc.nextLine();
			if(ss.equals("rect")){
				String str=sc.nextLine();
				b1.add(str);
				a1++;	
			}
			
			if(ss.equals("cir")){
				String st=sc.nextLine();
				b2.add(st);
				a2++;	
			}
			
		}
		Rectangle[] p1=new Rectangle[a1];
		Circle[]  p2=new Circle[a2];
		
		for(int i=0;i<a1;i++)
		{
			String c1=String.valueOf(b1.get(i));
			String[] sr=c1.split(" ");
			int d1 = Integer.parseInt(sr[0]);
			int d2 = Integer.parseInt(sr[1]);
			p1[i]=new Rectangle(d1,d2);
			
		}
		
		for(int j=0;j<a2;j++)
		{
			String c2=String.valueOf(b2.get(j));
			int d3 = Integer.parseInt(c2);
			p2[j]=new Circle(d3);
			
		}
		
		System.out.println(p1[0].sumAllPerimeter(a1, a2, p1, p2));
		System.out.println(p1[0].sumAllArea(a1, a2, p1, p2));
		
		
	}

}
